package com.leetcode.LC;

public class LC1475 {
    public int[] finalPrices(int[] prices) {

        for (int i = 0; i < prices.length; i++) {
            for (int j = i + 1; j < prices.length; j++) {
                if (prices[j] <= prices[i]) {
                    prices[i] = prices[i] - prices[j];
                    break;
                }
            }
        }
        return prices;

    }

    public static void main(String[] args) {
        for (int i : new LC1475().finalPrices(new int[]{8, 4, 6, 2, 3})) {
            System.out.print(i + ",");
        }
    }
}
